package com.example.chatclient;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class SendService {

	protected Socket socket;
	protected InputStream mmInStream;
	protected OutputStream mmOutStream;

	public SendService() {}
	
	public SendService(Socket socket) throws IOException {
		this.socket = socket;
		mmInStream = socket.getInputStream();
		mmOutStream = socket.getOutputStream();
	}

	public void write(String message) {
		try {
			if (this.socket != null
					&& this.socket.isConnected()) {
				byte[] buffer = message.getBytes("UTF-8");

				this.mmOutStream.write(buffer);
				this.mmOutStream.flush();
			}
		} catch (Exception e) {
		}
	}
}
